package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dao.TokenMapper;
import com.tencent.wxcloudrun.model.Token;
import com.tencent.wxcloudrun.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("tokenService")
public class TokenServiceImpl implements TokenService {
    @Autowired
    private TokenMapper tokenMapper;
    /**
     * 根据用户名id来查询用户对应的token
     * @param userId 用胡的id
     * @return 实例token
     */
    @Override
    public Token findTokenByUserId(int userId) {
        return tokenMapper.selectTokenByUserId(userId);
    }


    /**
     *添加token的方法
     * @param token token的实例
     * @return 受影响的条数
     */
    @Override
    public int addToken(Token token) {
        return tokenMapper.insertToken(token);
    }
}
